﻿#ifndef HALCONMODELMATCHWIDGET_H
#define HALCONMODELMATCHWIDGET_H

#include <QWidget>
#include <QSpinbox>
#include <QDoubleSpinbox>
#include <QLineEdit>
#include <QPushButton>
#include <QTabWidget>
#include <QCheckBox>
#include "WidgetRoiDraw.h"
#include "QtHalcon.h"


class HalconModelMatchWidget : public QWidget
{
    Q_OBJECT
public:
    explicit HalconModelMatchWidget(QWidget *parent = nullptr);
    void setImage(const QImage& img);
    ShapeMatchParam getParam();
    void setParam(const ShapeMatchParam& par);
signals:
    void sigParamChanged(ShapeMatchParam param);
protected:
    virtual void closeEvent(QCloseEvent* e) override;

private:
    void setupUI();
    void setupPageModelCreate();
    void setupPageModelFind();
    void initUI();
    void initConnection();
    void updateModelCreatePar();
    void updateModelFindPar();


private:
    QTabWidget* tabwgt;
    //createmodel
    WidgetRoiDraw* wgtRoiModelCreate;
    QSpinBox* spboxNumLevels;
    QSpinBox* spboxAngleStart;
    QDoubleSpinBox* dspboxAngleStep;
    QComboBox* cbboxOptimization;
    QComboBox* cbboxCreateShape;
    QComboBox* cbboxMetric;
    QSpinBox* spboxContrastHigh;
    QSpinBox* spboxContrastLow;
    QSpinBox* spboxPieceSizeMin;
    QSpinBox* spboxContrastMin;
    QSpinBox* spboxCenterPosRow;
    QSpinBox* spboxCenterPosCol;
    QPushButton* pbtnModelCreate;

    //findmodel
    WidgetRoiDraw* wgtRoiModelFind;
    QPushButton* pbtnOpenImage;
    QPushButton* pbtnOpenFolder;
    QPushButton* pbtnOpenPre;
    QPushButton* pbtnOpenNext;

    QDoubleSpinBox* dspboxMinScore;
    QSpinBox* spboxNumToFind;
    QDoubleSpinBox* dspboxMaxOverlap;
    QComboBox* cbboxSubPixel;
    QSpinBox* spboxNumLevelMin;
    QDoubleSpinBox* dspboxGreedness;
    QPushButton* pbtnModelFind;

    //var
    QImage mImg;
    ShapeMatchParam mParam;

};

#endif // HALCONMODELMATCHWIDGET_H
